package com.example.demo.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.entity.Husband;
import com.example.demo.service.HusbandService;

@Controller
@RequestMapping("husband")
public class HusbandController {

	@Resource
	private HusbandService husbandService;
	
	@GetMapping("add")
	public String insertView() {
		return "husband/add";
	}
	
	@PostMapping("addHusband")
	@ResponseBody
	public Object insertHandler(Husband husband) {
		return husbandService.addHusband(husband);
	}
	
	@GetMapping("by_id")
	@ResponseBody
	public Object getHusband(Integer id) {
		return husbandService.getById(id);
	}
	
}
